/*
 * CS_DUNGEON_CLEAR_LIST_V2.cpp
 *
 *  Created on: 2014. 4. 14.
 *      Author: the2
 */


#include "../../Command.h"

#include "../../User.h"
#include "../../NLogic/Space.h"

namespace ProjectZ { namespace NCommand {

void Command::CS_DUNGEON_CLEAR_LIST_V2(User * pUser, ::Network::Packet * pPacket)
{
	/*
	//중국용
	CS_DUNGEON_CLEAR_LIST_V2			0x0316
	{
	}

	SC_DUNGEON_CLEAR_LIST_V2			0x0317
	{
		s16 sAck;
		u16 count
		{
			u8	u8is_played;			// 0: 플레이안함, 1: 플레이함
			s8	s8clear_grade;			// -1 : NOT CLEAR, 0 : C, 1 : B, 2 : A, 3 : S, 4 : SS, 5 : SSS
		}
	}
	*/

	PREPARE_PACKET;

	if (NULL == pUser->GetSpace() )
	{
		DEBUGLOG("CS_DUNGEON_CLEAR_LIST_V2 NULL == pUser->GetSpace() || pUser->GetSpace()->GetData()._spaceType != NLogic::Space::SpaceType::WORLD");
		return;
	}

	::Network::Packet * pAck = ::Network::GETPACKETPOOL()->SEND_NEW();
	* pAck	<< static_cast<int16_t>(ACK_OK)
			<< static_cast<uint16_t>(MAX_DUNGEON_COUNT);
	for (int i = 0; i < MAX_DUNGEON_COUNT; i++)
	{
		int nRetValue = 0;
		if (false == pUser->GetDungeonClearInfo().GetValue(i, nRetValue))
		{
			DEBUGLOG("ERROR %s pUser->GetDungeonClearInfo().GetValue index %d GID : %d", __FUNCTION__, i, pUser->GetUserSeq());
		}

		if (0 == nRetValue)
			* pAck	<< static_cast<uint8_t>(0);
		else
			* pAck	<< static_cast<uint8_t>(1);

		int nRetPointValue = -1;
		if (false == pUser->GetDungeonClearPoint().GetValue(i, nRetPointValue))
		{
			DEBUGLOG("ERROR %s pUser->GetDungeonClearPoint().GetValue index %d GID : %d", __FUNCTION__, i, pUser->GetUserSeq());
		}
		* pAck	<< static_cast<int8_t>(nRetPointValue);
	}
	pAck->MakePacket(CMD_SC_DUNGEON_CLEAR_LIST_V2);
	pUser->Send(pAck);
}

} /*NCommand*/ } /*ProjectZ*/

